#include <bits/stdc++.h>
using namespace std;
int n, m, l, v, dis[100005], v0[100005], a[100005], p[100005], dp[100005];
struct node {
    int l1, r1;
    bool operator<(const node &b) const {
        if (l1 == b.l1) {
            return r1 < b.r1;
        }
        return l1 < b.l1;
    }
} s[100005], t[100005], t1[100005];
bool check(int x, int y) {
    long long dis1 = p[y] - dis[x];
    long long cmp1 = 1ll * v0[x] * v0[x] + 2ll * a[x] * dis1;
    if (cmp1 > 1ll * v * v) {
        return 1;
    }
    return 0;
}//chao 1
struct nd {
    int l, r, mn;
    nd () {
        mn = 1e9;
    }
} seg[100005 << 2];
void pu(int pos) {
    seg[pos].mn = min(seg[pos << 1].mn, seg[pos << 1 | 1].mn);
}
void build(int pos, int l, int r) {
    seg[pos].l = l, seg[pos].r = r;
    if (l == r) {
        seg[pos].mn = 1e9;
        return ;
    }
    int mid = l + r >> 1;
    build(pos << 1, l, mid);
    build(pos << 1 | 1, mid + 1, r);
    pu(pos);
}
void ud(int pos, int x, int v) {
    if (seg[pos].l == seg[pos].r) {
        seg[pos].mn = v;
        return ;
    }
    int mid = seg[pos].l + seg[pos].r >> 1;
    if (x <= mid) {
        ud(pos << 1, x, v);
    } else {
        ud(pos << 1 | 1, x, v);
    }
    pu(pos);
}
int query(int pos, int l, int r) {
    if (l <= seg[pos].l && seg[pos].r <= r) {
        return seg[pos].mn;
    }
    int mid = seg[pos].l + seg[pos].r >> 1, res = 1e9;
    if (l <= mid) {
        res = min(res, query(pos << 1, l, r));
    }
    if (mid < r) {
        res = min(res, query(pos << 1 | 1, l, r));
    }
    return res;
}
void solve() {
    cin >> n >> m >> l >> v;
    for (int i = 1; i <= n; i++) {
        cin >> dis[i] >> v0[i] >> a[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> p[i];
    }
    sort(p + 1, p + m + 1);
    int tot = 0;
    for (int i = 1; i <= n; i++) {
        int st = lower_bound(p + 1, p + m + 1, dis[i]) - p;
        if (st > m) {
            continue;
        }
        int ed = m;
        if (a[i] < 0) {
            int ll1 = st, rr1 = -1;
            /*
            int lll = st, rrr = m;
            while (lll <= rrr) {
                int mid = lll + rrr >> 1;
                int dis1 = p[mid] - dis[i];
                int cmp = v0[i] * v0[i] + 2 * a[i] * dis1;
                if (cmp <= 0) {
                    rrr = mid - 1;
                } else {
                    ed = mid;
                    lll = mid + 1;
                }
            }
            */
            while (st <= ed) {
                int mid = st + ed >> 1;
                if (check(i, mid)) {
                    st = mid + 1;
                    rr1 = mid;
                } else {
                    ed = mid - 1;
                }
            }
            if (ll1 <= rr1) {
                s[++tot] = {ll1, rr1};
            }
        } else {
            int ll1 = n + 1, rr1 = ed;
            while (st <= ed) {
                int mid = st + ed >> 1;
                if (check(i, mid)) {
                    ed = mid - 1;
                    ll1 = mid;
                } else {
                    st = mid + 1;
                }
            }
            if (ll1 <= rr1) {
                s[++tot] = {ll1, rr1};
            }
        }
    }
    cout << tot << " ";
    if (!tot) {
        cout << m << "\n";
        return ;
    }
    sort(s + 1, s + tot + 1);
    int tot1 = 0;
    t[++tot1] = s[1];
    for (int i = 2; i <= tot; i++) {
        if (s[i].l1 == t[tot1].l1) {
            continue;
        }
        t[++tot1] = s[i];
    }
    int tot2 = 0;
    t1[++tot2] = t[tot1];
    for (int i = tot1 - 1; i >= 1; i--) {
        if (t[i].r1 >= t1[tot2].r1) {
            continue;
        }
        t1[++tot2] = t[i];
    }
    reverse(t1 + 1, t1 + tot2 + 1);
    //for (int i = 1; i <= tot2; i++) {
    //    cout << t1[i].l1 << " " << t1[i].r1 << "\n";
    //}
    build(1, 0, tot2);
    dp[0] = 0;
    dp[1] = 1;
    ud(1, 0, 0);
    ud(1, 1, 1);
    for (int i = 2; i <= tot2; i++) {
        int lst = i;
        int l1 = 1, r1 = i;
        while (l1 <= r1) {
            int mid = l1 + r1 >> 1;
            if (t1[mid].r1 >= t1[i].l1) {
                lst = mid;
                r1 = mid - 1;
            } else {
                l1 = mid + 1;
            }
        }
        lst--;
        if (lst != i) {
            dp[i] = query(1, lst, i - 1) + 1;
        } else {
            dp[i] = dp[i - 1] + 1;
        }
        ud(1, i, dp[i]);
    }
    cout << m - dp[tot2] << "\n";
}
signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}
